_settings_lock ensures only one thread can execute transient_settings…#289
Merged
lirshindalman merged 2 commits intomasterfrom Feb 25, 2026
Merged
_settings_lock ensures only one thread can execute transient_settings…#289lirshindalman merged 2 commits intomasterfrom
lirshindalman merged 2 commits intomasterfrom
Conversation
added 2 commits
February 23, 2026 16:15
…() at a time, eliminating the window where get_settings() returns empty Settings() Adding get_mapping_from_secret_type_to_class.cache_clear() to cache_bust() ensures any stale plugin mapping cached during a race window is always invalidated
omriyoffe-panw
approved these changes
Feb 24, 2026
bo156
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File changed: detect_secrets/settings.py
Added threading.Lock (_settings_lock) - serializes access to transient_settings() so only one thread can modify/clear the global caches at a time, eliminating the race window.
Added get_mapping_from_secret_type_to_class.cache_clear() to cache_bust() - ensures any stale plugin-type mapping built from empty settings is always invalidated when caches are cleared.
Impact
No API changes — transient_settings() and cache_bust() signatures are unchanged
No performance impact on single-threaded usage — uncontended lock acquisition is ~50ns
Fixes concurrent usage — multiple threads calling transient_settings() will now serialize correctly instead of corrupting shared state
Backward compatible — the lock only adds safety; existing single-threaded callers are unaffected